package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/3/4 15:29
 * @description
 */
public class Code334 {
    public static void main(String[] args) {
        System.out.println(new Code334().increasingTriplet(new int[] {2, 1, 5, 0, 4, 6}));
    }

    public boolean increasingTriplet(int[] nums) {
        if (nums.length < 3) {
            return false;
        }
        for (int i = 0; i <= nums.length - 3; i++) {
            if (nums[i] < nums[i + 1]) {
                int second = nums[i + 1];
                for (int j = i + 1; j <= nums.length - 2; j++) {
                    if (second < nums[j + 1]) { return true; }
                    if (second > nums[j + 1] && nums[i] < nums[j + 1]) { second = nums[j + 1]; }
                }
            }
        }
        return false;
    }
}
